import 'package:flutter/material.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
///勘察员抽屉
class ScoutDrawer extends StatefulWidget {
  @override
  _ScoutDrawerState createState() => _ScoutDrawerState();
}

class _ScoutDrawerState extends State<ScoutDrawer> {
  List<String> _titleList = ["保司信息","账号设置","切换账号","服务地区设置","退出登录"];
  List<String> images = ["baosi.png","user.png","qiehuan.png","severs_location.png","tuichu.png"];
  @override
  Widget build(BuildContext context) {
    return  Drawer(
      child:SafeArea(
        child: SingleChildScrollView(
          child: Column(
            children: [
              SizedBox(
                height: setWidth(28),
              ),
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(
                    width: setWidth(19),
                  ),
                  Container(
                    height: setWidth(60),
                    width: setWidth(60),
                    decoration: BoxDecoration(
                        color: Color(0xffC4C4C4),
                        borderRadius: BorderRadius.circular(30)
                    ),
                  ),
                  SizedBox(
                    width: setWidth(12),
                  ),
                  Expanded(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          child: Text("汽车养护中心",style: TextStyle(color: Color(0xff323232),fontSize: setSp(16),fontWeight: FontWeight.w600),),
                        ),
                        SizedBox(
                          height: setWidth(10),
                        ),
                        Container(
                          child: Text("ID:15245898476",style: TextStyle(color: Color(0xff686868),fontSize: setSp(12)),),
                        )

                      ],
                    ),
                  )
                ],
              ),
              Container(
                margin: EdgeInsets.only(left: setWidth(16),top: setWidth(20)),
                child: ListView.builder(
                    shrinkWrap: true,
                    physics: NeverScrollableScrollPhysics(),
                    itemCount:_titleList.length ,
                    itemBuilder: (context,index){
                      return GestureDetector(
                          behavior: HitTestBehavior.opaque,
                          onTap: (){
                            switch(index){
                              case 0:urlPush(context, "yuntu://insurance_company_info");break;
                              case 1:urlPush(context,"yuntu://account_setting");break;
                              case 2:urlPush(context,"yuntu://check_role");break;
                              case 3:urlPush(context,"yuntu://service_loaction_set");break;

                            }

                          },
                          child: _item(_titleList[index],images[index]));
                    }),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _item(String title,String image) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: EdgeInsets.only(top: setWidth(20)),
          child:Row(
            children: [
              Container(
                child: Image.asset("assets/images/$image",fit: BoxFit.cover,),
                width: setWidth(20),
                height: setWidth(20),
              ),
              SizedBox(
                width: setWidth(11),
              ),
              Container(
                child: Text(title,style: TextStyle(color: Color(0xff323232),fontSize: setSp(16)),),
              )
            ],
          ) ,
        ),
        SizedBox(
          height: setWidth(15),
        ),
        Container(
          margin: EdgeInsets.only(left: setWidth(16)),
          height: setWidth(0.5),
          color: Color(0xffF0F0F0),
        ),
      ],
    );
  }
}
